/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.site.user.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author zhanjun
 */
@Entity
@Table(name = "tb_role")
@NamedQueries({
    @NamedQuery(name = "TbRole.findAll", query = "SELECT t FROM TbRole t"),
    @NamedQuery(name = "TbRole.findByIdRole", query = "SELECT t FROM TbRole t WHERE t.idRole = :idRole"),
    @NamedQuery(name = "TbRole.findByRoleName", query = "SELECT t FROM TbRole t WHERE t.roleName = :roleName"),
    @NamedQuery(name = "TbRole.findByRoleDesc", query = "SELECT t FROM TbRole t WHERE t.roleDesc = :roleDesc"),
    @NamedQuery(name = "TbRole.findByRoleType", query = "SELECT t FROM TbRole t WHERE t.roleType = :roleType"),
    @NamedQuery(name = "TbRole.findByCreateTime", query = "SELECT t FROM TbRole t WHERE t.createTime = :createTime"),
    @NamedQuery(name = "TbRole.findByCreateUser", query = "SELECT t FROM TbRole t WHERE t.createUser = :createUser"),
    @NamedQuery(name = "TbRole.findBySign", query = "SELECT t FROM TbRole t WHERE t.sign = :sign")})
public class TbRole implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID_ROLE")
    private String idRole;
    @Column(name = "ROLE_NAME")
    private String roleName;
    @Column(name = "ROLE_DESC")
    private String roleDesc;
    @Column(name = "ROLE_TYPE")
    private String roleType;
    @Column(name = "CREATE_TIME")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;
    @Column(name = "CREATE_USER")
    private String createUser;
    @Column(name = "SIGN")
    private String sign;
    @ManyToMany(mappedBy = "tbRoleSet",fetch=FetchType.LAZY)
    private Set<TbGroup> tbGroupSet;
    @ManyToMany(mappedBy = "tbRoleSet",fetch=FetchType.LAZY)
    private Set<TbUser> tbUserSet;

    public TbRole() {
    }

    public TbRole(String idRole) {
        this.idRole = idRole;
    }

    public String getIdRole() {
        return idRole;
    }

    public void setIdRole(String idRole) {
        this.idRole = idRole;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRoleDesc() {
        return roleDesc;
    }

    public void setRoleDesc(String roleDesc) {
        this.roleDesc = roleDesc;
    }

    public String getRoleType() {
        return roleType;
    }

    public void setRoleType(String roleType) {
        this.roleType = roleType;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public Set<TbGroup> getTbGroupSet() {
        return tbGroupSet;
    }

    public void setTbGroupSet(Set<TbGroup> tbGroupSet) {
        this.tbGroupSet = tbGroupSet;
    }

    public Set<TbUser> getTbUserSet() {
        return tbUserSet;
    }

    public void setTbUserSet(Set<TbUser> tbUserSet) {
        this.tbUserSet = tbUserSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRole != null ? idRole.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TbRole)) {
            return false;
        }
        TbRole other = (TbRole) object;
        if ((this.idRole == null && other.idRole != null) || (this.idRole != null && !this.idRole.equals(other.idRole))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.site.user.pojo.TbRole[idRole=" + idRole + "]";
    }

}
